package com.cql.controller;

//import com.cql.configuration.InstanceFallBack;
import Configutation.FeignMultipartSupportConfig1;
import com.cql.configuration.InstanceFallBack;
import com.cql.pojo.Person;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

//@Component(value = "changqilong")
@FeignClient(qualifier = "aa",value = "eureka-client-service", fallback = InstanceFallBack.class, configuration = FeignMultipartSupportConfig1.class) //如果需要调用注册中心服务方那么name/value就是注册中心服务方的spring.application.name
//但是也可以使用name配合url一起来使用
//@Qualifier("aa") //因为异常回退需要实现该接口，且该接口不能被注入到spring中，所以需要提供一个controller来调用自己的方法，但是也正是因为有了该接口和实现类，所以需要起别名
public interface InstanceClient {

    @RequestMapping(value = "/cql/hello", method = RequestMethod.POST)
    @ResponseBody //该注解必须有
   String sayHello(@RequestParam("name") String name) ;

    @RequestMapping(value = "/cql/hello/{name}", method = RequestMethod.GET)
    @ResponseBody //该注解必须有
    String sayHello2(@PathVariable("name") String name) ;

    @RequestMapping(value = "/cql/getPerson", method = RequestMethod.POST, consumes = "application/json")
    @ResponseBody
    String getPerson(@RequestBody Person param);

    @RequestMapping(value = "/cql/fileUpload", method = RequestMethod.POST, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE}, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public String fileUpload(@RequestPart(value = "file") MultipartFile file);

}
